<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars
$FileName       = "ais_closing_taxrenum.php";
$FileTemplate   = "ais_closing_taxrenum_form.html";
$ProcedureName  = "renumtax";
$SubHeaderTitle = "Closing - Tax Renumbering";
$HTMLGridList  = "TaxRenum";

//******* ACTION *********

if (GetParam("Action","")=="Renumber") {

    if(!GetParam("periodYear","") || !GetParam("periodMonth","")){
         print "
              <script>
              alert('Please Select Year and Month!\\nNo progress... ');
              </script>
        ";
    }else{
        $Year = GetParam("periodYear","");
        $Month = GetParam("periodMonth","");

        if (strlen($Year)>2) $tahun = substr($Year,-2);
        if ($Month*1<10) $bulan = "0".$Month;
        else $bulan = $Month;


        /*if($Month-1 == 0){
             $bulanBefore = 12;
             if (strlen($Year)>2) $tahunBefore = substr($Year-1,-2);
        }else{
            if ($Month*1<10) $bulanBefore = "0".($Month-1);
            else $bulanBefore = $Month-1;
            if (strlen($Year)>2) $tahunBefore = substr($Year,-2);
        }
        $SQL = "call ".$ProcedureName."('".$tahun.$bulan."','".$tahunBefore.$bulanBefore."')";*/

        $SQL = "call ".$ProcedureName."('".$tahun.$bulan."','".GetOfficeID()."')";
        $DBConnection->dbc->query($SQL);

        print "<script>alert('Renumbering Success!')</script>";

    }

}


//******* SHOW FORM CONTENT *********

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);
$TBS->MergeBlock("monthformblk",GetArrayMonth());
$ArrayYear[0]["year"] = date("Y");
$ArrayYear[1]["year"] = date("Y")-1;
$TBS->MergeBlock("yearformblk",$ArrayYear);
$TBS->Show();

?>
